package com.cskaoyan._02charstream._06copy;

import com.cskaoyan.utils.FileUtils;

import java.io.*;

/**
 * @description:
 * @author: 景天
 * @date: 2023/2/20 10:54
 **/

public class Demo {
    public static void main(String[] args) throws IOException {
        // 创建输入流对象
        //InputStreamReader in = new InputStreamReader(
        //        new FileInputStream("D:\\a.txt"));

        //InputStreamReader in = new InputStreamReader(
        //        new FileInputStream("D:\\a.jpg"));

        InputStreamReader in = new InputStreamReader(
                new FileInputStream("D:\\aa.mp4"));
        // 输出流对象
        //OutputStreamWriter out = new OutputStreamWriter(
        //        new FileOutputStream("copy_a.txt"));
        //OutputStreamWriter out = new OutputStreamWriter(
        //        new FileOutputStream("copy_a.jpg"));
        OutputStreamWriter out = new OutputStreamWriter(
                new FileOutputStream("copy_aa.mp4"));

        // 文件复制操作,使用工具类
        // 文本文件 10ms  2ms
        // 图片文件 113ms 51ms
        // 视频文件
        // 单字符
        long start = System.currentTimeMillis();

        //FileUtils.copy3(in, out);
        FileUtils.copy4(in, out);


        long end = System.currentTimeMillis();
        System.out.println(end - start + "ms");

        // close
        in.close();
        out.close();

    }
}
